package com.cuijq.ms.flyweight.v2;

import com.cuijq.ms.flyweight.v1.ChessPiece;
import java.util.HashMap;
import java.util.Map;

/**
 * @author by CuiJQ
 * @Classname ChessPieceUnitFactory
 * @Description ChessPieceUnitFactory Description
 * @Date 2021/5/26 23:58
 */
public class ChessPieceUnitFactory {

  private static final Map<Integer, ChessPieceUnit> pieces = new HashMap<>();

  static {
    pieces.put(1, new ChessPieceUnit(1, "車", ChessPieceUnit.Color.BLACK));
    pieces.put(2, new ChessPieceUnit(2, "馬",
        ChessPieceUnit.Color.BLACK)); //...省略摆放其他棋子的代码...
  }

  public static ChessPieceUnit getChessPiece(int chessPieceId) {
    return pieces.get(chessPieceId);
  }
}
